

import { WatchBroadcastMessage, WatchBroadcastType, PlayerSchema as BasePlayerSchema } from "sgc";

import { error, log } from "cc";
import { DescMessage, fromBinary, Message, MessageShape } from "@bufbuild/protobuf";
import { BaseManager, Manager } from "@shimotsuki/core";
import { SocketEvent, SocketRoute } from "../ws/game";




// 定义 RouteToClassMap 对象，映射每个事件响应类型到对应的类构造函数
const RouteToClassMap: { [key in SocketEvent]?: DescMessage } = {
    "PlayerStatusChanged": BasePlayerSchema,
};

const filter: (SocketEvent | SocketRoute)[] = []

// 扩展 Manager 接口，添加 WatchSystem 属性
declare module '@shimotsuki/core' {
    interface Manager {
        watch: WatchSystem;
    }
}

// 定义一个类型，根据传入的 route 获取对应的类构造函数类型，并调用其 fromBinary 方法的返回类型

/**观战系统 */
export class WatchSystem extends BaseManager {

    constructor(cat: Manager) {
        super(cat);

        this.init()
    }

    init() {
        this.cat.event.on<SocketEvent>('WatchBroadcast', this.onWatchBroadcastHandler, this);
    }

    private onWatchBroadcastHandler(e: WatchBroadcastMessage) {

        // TODO 处理观战广播


    }


}